#ifndef Display_H
#define Display_H

#if defined(DISP_TM1651) || defined(DISP_AIP650)
// .GFEDCBA
#define SHOWA 0x77
#define SHOWb 0x7C
#define SHOWC 0x39
#define SHOWd 0x5E
#define SHOWE 0x79
#define SHOWF 0x71
#define SHOWH 0x76
#define SHOWL 0x38
#define SHOWn 0x54
#define SHOWo 0x5C
#define SHOWP 0x73
#define SHOWr 0x50
#define SHOWS 0x6D
#define SHOWU 0x3E

#define SHOW0 0x3F
#define SHOW1 0x06
#define SHOW2 0x5B
#define SHOW3 0x4F
#define SHOW4 0x66
#define SHOW5 0x6D
#define SHOW6 0x7D
#define SHOW7 0x07
#define SHOW8 0x7F
#define SHOW9 0x6F
#endif // DISP_TM1651

#ifdef DISP_HC164
// EDB.AFGC
#define SHOWA 0xAF
#define SHOWb 0xC7
#define SHOWC 0xCC
#define SHOWd 0xE3
#define SHOWE 0xCE
#define SHOWF 0x8E
#define SHOWH 0xA7
#define SHOWL 0xC4
#define SHOWn 0x83
#define SHOWo 0xC3
#define SHOWP 0xAE
#define SHOWr 0x82
#define SHOWS 0x4F
#define SHOWU 0xE5

#define SHOW0 0xED
#define SHOW1 0x21
#define SHOW2 0xEA
#define SHOW3 0x6B
#define SHOW4 0x27
#define SHOW5 0x4F
#define SHOW6 0xCF
#define SHOW7 0x29
#define SHOW8 0xEF
#define SHOW9 0x6F
#endif // DISP_HC164

#define ERR_COUNT 11

#ifdef Display_Variable
#define Display_Extern
const U8 DispErrTab[ERR_COUNT][8][3] =
    {
        /* err H8, err L8, 1:One Disp */
        {
            SHOW0, SHOW0, 1, //  00
            SHOW0, SHOW1, 1, //  01
            SHOW0, SHOW2, 1, //  02
            SHOW0, SHOW3, 1, //  03
            SHOWo, SHOW0, 1, //  o0
            SHOWo, SHOW1, 1, //  o1
            SHOWo, SHOW2, 1, //  o2
            SHOWo, SHOW3, 1, //  o3
        },

        {
            SHOWo, SHOW4, 1, //  o4
            SHOWC, SHOW7, 1, //  C7
            SHOWo, SHOW6, 1, //  o6
            SHOWo, SHOW7, 1, //  o7
            SHOWo, SHOW8, 1, //  o8
            SHOWH, SHOWC, 1, //  HC
            SHOWo, SHOWA, 1, //  oA
            SHOWo, SHOWC, 1, //  oC
        },

        {
            SHOWE, SHOWH, 0, //  EH
            SHOWA, SHOW2, 0, //  A2
            SHOWL, SHOW8, 0, //  L8
            SHOWL, SHOW9, 0, //  L9
            SHOWE, SHOW0, 0, //  E0
            SHOWE, SHOW1, 0, //  E1
            SHOWF, SHOWF, 0, //  FF
            SHOWC, SHOW8, 0, //  C8
        },

        {
            SHOWF, SHOW0, 0, //  F0
            SHOWF, SHOW1, 0, //  F1
            SHOWF, SHOW2, 0, //  F2
            SHOWF, SHOW3, 0, //  F3
            SHOWF, SHOW4, 0, //  F4
            SHOWF, SHOW5, 0, //  F5
            SHOWF, SHOW6, 0, //  F6
            SHOWF, SHOW7, 0, //  F7
        },

        {
            SHOWC, SHOW0, 0, //  C0
            SHOWC, SHOW1, 0, //  C1
            SHOWC, SHOW2, 0, //  C2
            SHOWC, SHOW3, 0, //  C3
            SHOWC, SHOW4, 0, //  C4
            SHOWC, SHOW5, 0, //  C5
            SHOWC, SHOW6, 0, //  C6
            SHOWC, SHOW9, 0, //  C9
        },

        {
            SHOWU, SHOW0, 0, //  U0
            SHOWU, SHOW1, 0, //  U1
            SHOWU, SHOW2, 0, //  U2
            SHOWU, SHOW3, 0, //  U3
            SHOWU, SHOW4, 0, //  U4
            SHOWU, SHOW5, 0, //  U5
            SHOWU, SHOW6, 0, //  U6
            SHOWU, SHOW7, 0, //  U7
        },

        {
            SHOWU, SHOW8, 0, //  U8
            SHOWU, SHOW9, 0, //  U9
            SHOWU, SHOWA, 0, //  UA
            SHOWU, SHOWb, 0, //  Ub
            SHOWU, SHOWC, 0, //  UC
            SHOWU, SHOWd, 0, //  Ud
            SHOWU, SHOWE, 0, //  UE
            SHOWH, SHOW8, 0, //  H8
        },

        {
            SHOWH, SHOW0, 0, //  H0
            SHOWH, SHOW1, 0, //  H1
            SHOWH, SHOW2, 0, //  H2
            SHOWH, SHOW3, 0, //  H3
            SHOWH, SHOW4, 0, //  H4
            SHOWH, SHOW5, 0, //  H5
            SHOWH, SHOW6, 0, //  H6
            SHOWE, SHOWU, 0, //  H7
        },

        {
            SHOWP, SHOW1, 0, //  P1
            SHOWP, SHOW2, 0, //  P2
            SHOWP, SHOW4, 0, //  P4
            SHOWP, SHOW5, 0, //  P5
            SHOWP, SHOW6, 0, //  P6
            SHOWP, SHOW7, 0, //  P7
            SHOWP, SHOW8, 0, //  P8
            SHOWP, SHOW9, 0, //  P9
            /*
            SHOWL, SHOW0, 0, //  L0
            SHOWL, SHOW1, 0, //  L1
            SHOWL, SHOW2, 0, //  L2
            SHOWL, SHOW3, 0, //  L3
            SHOWL, SHOW4, 0, //  L4
            SHOWL, SHOW5, 0, //  L5
            SHOWL, SHOW6, 0, //  L6
            SHOWL, SHOW7, 0, //  L7
            */
        },

        {
            SHOWE, SHOW2, 0, //  E2
            SHOWE, SHOW3, 0, //  E3
            SHOWE, SHOW4, 0, //  E4
            SHOWE, SHOW5, 0, //  E5
            SHOWE, SHOW6, 0, //  E6
            SHOWE, SHOW7, 0, //  E7
            SHOWE, SHOW8, 0, //  E8
            SHOWE, SHOW9, 0, //  E9
        },

        {
            SHOWC, SHOWF, 0, //  CF
            SHOWE, SHOWb, 0, //  Eb
            SHOWF, SHOWP, 0, //  FP，水满保护；
            SHOWE, SHOWC, 0, //  EC
            SHOWE, SHOWE, 0, //  EE
            SHOWE, SHOWF, 0, //  EF
            SHOWE, SHOWP, 0, //  EP
            SHOWE, SHOWA, 0, //  EA
        },
};





const U8 DispNubTab[16] =
    {
        SHOW0, SHOW1, SHOW2, SHOW3, SHOW4,
        SHOW5, SHOW6, SHOW7, SHOW8, SHOW9,
        SHOWA, SHOWb, SHOWC, SHOWd, SHOWE, SHOWF};

static struct
{
    U8 i;
    U8 j;
    U8 timer;
} errDisp;

#else
#define Display_Extern extern
#endif

Display_Extern U8 stat_Disp888;

typedef struct
{
    U8 H8;
    U8 L8;
    U8 D8;
    ram_byte L1;
    ram_byte L2;
    ram_byte L3;
} dispCode_typeDef;

typedef struct
{
    U8 refresh;
    U8 adrr;
    U8 jump;
    U8 wifi;
    U8 power;
    U8 setTest;
    U8 humi;
    U8 childlock;

    U16 wifi_light;
} dispTimer_typeDef;

extern dispCode_typeDef dispCode;
extern dispTimer_typeDef dispTimer;
#define dispCodeL1 dispCode.L1.byte
#define f_DispWifi1 dispCode.L1.bit.b0
#define f_DispWifi2 dispCode.L1.bit.b1
#define f_DispPower1 dispCode.L1.bit.b2
#define f_DispPower2 dispCode.L1.bit.b3
#define f_DispDot dispCode.L1.bit.b4
#define f_DispHeater dispCode.L1.bit.b5  //点亮加热器指示灯 是Bit5















































































































































































































































































































































//#define f_DispHeater dispCode.L1.bit.b6


#define dispCodeL2 dispCode.L2.byte
#define f_DispHealth dispCode.L2.bit.b0
#define f_DispCool1 dispCode.L2.bit.b2
#define f_DispCool2 dispCode.L2.bit.b3
#define f_DispHeat1 dispCode.L2.bit.b4
#define f_DispHeat2 dispCode.L2.bit.b5
#define f_DispTimer1 dispCode.L2.bit.b6
#define f_DispTimer2 dispCode.L2.bit.b7

#define dispCodeL3 dispCode.L3.byte
#define f_DispTimer dispCode.L3.bit.b0
#define f_DispError dispCode.L3.bit.b3
#define f_DispDefrost dispCode.L3.bit.b5
#define f_DispRun dispCode.L3.bit.b7

Display_Extern ram_byte ErrorFlagQT;
#define ErrFlagQT ErrorFlagQT.byte
#define f_RoomErrQT ErrorFlagQT.bit.b0
#define f_TubeErrQT ErrorFlagQT.bit.b1
#define f_JumpErrQT ErrorFlagQT.bit.b2
#define f_ZeroErrQT ErrorFlagQT.bit.b3

Display_Extern ram_byte ErrorFlag;
#define ErrFlag ErrorFlag.byte
#define f_RoomErr ErrorFlag.bit.b0
#define f_TubeErr ErrorFlag.bit.b1
#define f_ZeroErr ErrorFlag.bit.b2
#define f_MotorErr ErrorFlag.bit.b3
#define f_HeaterErr ErrorFlag.bit.b4
#define f_waterErr ErrorFlag.bit.b5
#define f_GasLeakErr ErrorFlag.bit.b6
#define f_GasSensorErr ErrorFlag.bit.b7

Display_Extern ram_byte DispErrFlag[ERR_COUNT];
#define errDisp1 DispErrFlag[0].byte
#define f_code_00 DispErrFlag[0].bit.b0
#define f_code_01 DispErrFlag[0].bit.b1
#define f_code_02 DispErrFlag[0].bit.b2
#define f_code_03 DispErrFlag[0].bit.b3
#define f_code_o0 DispErrFlag[0].bit.b4
#define f_code_o1 DispErrFlag[0].bit.b5
#define f_code_o2 DispErrFlag[0].bit.b6
#define f_code_o3 DispErrFlag[0].bit.b7

#define errDisp2 DispErrFlag[1].byte
#define f_code_o4 DispErrFlag[1].bit.b0
#define f_code_C7 DispErrFlag[1].bit.b1
#define f_code_o6 DispErrFlag[1].bit.b2
#define f_code_o7 DispErrFlag[1].bit.b3
#define f_code_o8 DispErrFlag[1].bit.b4
#define f_code_HC DispErrFlag[1].bit.b5
#define f_code_oA DispErrFlag[1].bit.b6
#define f_code_oC DispErrFlag[1].bit.b7

#define errDisp3 DispErrFlag[2].byte
#define f_code_EH DispErrFlag[2].bit.b0
#define f_code_A2 DispErrFlag[2].bit.b1
#define f_code_L8 DispErrFlag[2].bit.b2
#define f_code_L9 DispErrFlag[2].bit.b3
#define f_code_E0 DispErrFlag[2].bit.b4
#define f_code_E1 DispErrFlag[2].bit.b5
#define f_code_FF DispErrFlag[2].bit.b6
#define f_code_C8 DispErrFlag[2].bit.b7

#define errDisp4 DispErrFlag[3].byte
#define f_code_F0 DispErrFlag[3].bit.b0
#define f_code_F1 DispErrFlag[3].bit.b1
#define f_code_F2 DispErrFlag[3].bit.b2
#define f_code_F3 DispErrFlag[3].bit.b3
#define f_code_F4 DispErrFlag[3].bit.b4
#define f_code_F5 DispErrFlag[3].bit.b5
#define f_code_F6 DispErrFlag[3].bit.b6
#define f_code_F7 DispErrFlag[3].bit.b7

#define errDisp5 DispErrFlag[4].byte
#define f_code_C0 DispErrFlag[4].bit.b0
#define f_code_C1 DispErrFlag[4].bit.b1
#define f_code_C2 DispErrFlag[4].bit.b2
#define f_code_C3 DispErrFlag[4].bit.b3
#define f_code_C4 DispErrFlag[4].bit.b4
#define f_code_C5 DispErrFlag[4].bit.b5
#define f_code_C6 DispErrFlag[4].bit.b6
#define f_code_C9 DispErrFlag[4].bit.b7

#define errDisp6 DispErrFlag[5].byte
#define f_code_U0 DispErrFlag[5].bit.b0
#define f_code_U1 DispErrFlag[5].bit.b1
#define f_code_U2 DispErrFlag[5].bit.b2
#define f_code_U3 DispErrFlag[5].bit.b3
#define f_code_U4 DispErrFlag[5].bit.b4
#define f_code_U5 DispErrFlag[5].bit.b5
#define f_code_U6 DispErrFlag[5].bit.b6
#define f_code_U7 DispErrFlag[5].bit.b7

#define errDisp7 DispErrFlag[6].byte
#define f_code_U8 DispErrFlag[6].bit.b0
#define f_code_U9 DispErrFlag[6].bit.b1
#define f_code_UA DispErrFlag[6].bit.b2
#define f_code_Ub DispErrFlag[6].bit.b3
#define f_code_UC DispErrFlag[6].bit.b4
#define f_code_Ud DispErrFlag[6].bit.b5
#define f_code_UE DispErrFlag[6].bit.b6
#define f_code_H8 DispErrFlag[6].bit.b7

#define errDisp8 DispErrFlag[7].byte
#define f_code_H0 DispErrFlag[7].bit.b0
#define f_code_H1 DispErrFlag[7].bit.b1
#define f_code_H2 DispErrFlag[7].bit.b2
#define f_code_H3 DispErrFlag[7].bit.b3
#define f_code_H4 DispErrFlag[7].bit.b4
#define f_code_H5 DispErrFlag[7].bit.b5
#define f_code_H6 DispErrFlag[7].bit.b6
#define f_code_EU DispErrFlag[7].bit.b7

#define errDisp9 DispErrFlag[8].byte
#define f_code_P1 DispErrFlag[8].bit.b0
#define f_code_P2 DispErrFlag[8].bit.b1
#define f_code_P4 DispErrFlag[8].bit.b2
#define f_code_P5 DispErrFlag[8].bit.b3
#define f_code_P6 DispErrFlag[8].bit.b4
#define f_code_P7 DispErrFlag[8].bit.b5
#define f_code_P8 DispErrFlag[8].bit.b6
#define f_code_P9 DispErrFlag[8].bit.b7

#define errDisp10 DispErrFlag[9].byte
#define f_code_E2 DispErrFlag[9].bit.b0
#define f_code_E3 DispErrFlag[9].bit.b1
#define f_code_E4 DispErrFlag[9].bit.b2
#define f_code_E5 DispErrFlag[9].bit.b3
#define f_code_E6 DispErrFlag[9].bit.b4
#define f_code_E7 DispErrFlag[9].bit.b5
#define f_code_E8 DispErrFlag[9].bit.b6
#define f_code_E9 DispErrFlag[9].bit.b7

#define errDisp11 DispErrFlag[10].byte
#define f_code_CF DispErrFlag[10].bit.b0
#define f_code_Eb DispErrFlag[10].bit.b1
#define f_code_FP DispErrFlag[10].bit.b2
#define f_code_EC DispErrFlag[10].bit.b3
#define f_code_EE DispErrFlag[10].bit.b4
#define f_code_EF DispErrFlag[10].bit.b5
#define f_code_EP DispErrFlag[10].bit.b6
#define f_code_EA DispErrFlag[10].bit.b7




 



void DisplayAct(void);
void jumpTypeDisp(void);
void adrressDisp(void);
void LightDisp(void);
void setTestDisp(void);

void DisplayTime(void);    // called in systime.c per 100ms
void DisplayTime_1s(void); // called in systime.c per 1s

U8 DispErrCode(void);
void errCycleDisp(void);

#if defined(DISP_TM1651) || defined(DISP_AIP650)
void DispDriver(void);
void IIC_Start(void);
void IIC_Stop(void);
void IIC_Byte(U8);
void IIC_delay_nop(void);
#endif // DISP_TM1651

#ifdef DISP_HC164
void DispDriver(void);
void Display_driver_HC164(U8);
#endif // DISP_HC164

#endif
